class Solution(object):
    def maxProfit(self, prices):
        profit = 0
        min = prices[0]
        for e in prices:
            if e < min:
                min = e
            profit=max(profit,e-min)
        return profit
x=Solution()
print(x.maxProfit([7,1,5,3,6,4]))